<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="copyright" content="www.apicloud.com" />
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>舆情处置完毕</title>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />

	<style>
		html {
			height: 100%;
		}

		body {
			height: 100%;
			width: 100%;
		}

		input {
			height: 50px;
			font-size: 18px;
			color: #8E8C8C;
			width: 80%;
		}

		input::-webkit-input-placeholder {
			color: #ccc;
		}
		/* 头部样式 */

		#header {
			border-bottom: 1px solid #8E8C8C;
		}

		.topbar {
			height: 50px;
			border-bottom: 1px solid #DDDFE3;
		}

		#title {
			color: #333;
		}

		.back {
			float: left;
			padding-right: 30px;
		}

		.back img {
			height: 30px;
			margin-top: 10px;
			margin-left: 10px;
			margin-bottom: 10px;
		}

		.topbar .title {
			line-height: 50px;
			font-size: 20px;
			position: absolute;
			left: 50%;
			-webkit-transform: translateX(-50%);
			transform: translateX(-50%);
		}
		/* 内容样式 */

		#main {
			width: 100%;
			height: 100%;
			margin: 0px;
			padding: 0px;
		}

		#main .select {
			width: 100%;
			text-align: left;
			font-size: 1.3em;
			color: #333;
		}

		#main #checkDiv {
			width: 100%;
			text-align: left;
			font-size: 1.3em;
			color: #333;
		}

		#main #checkShowDiv {
			width: 100%;
			text-align: left;
			font-size: 1.3em;
			color: #333;
		}

		#main .option {
			width: 90%;
			margin: 0px 5%;
			margin-top: 10px;
			font-weight: bold;
		}

		#main .option .radio {
			width: 40%;
			font-size: 1em;
			font-weight: normal;
			padding: 5px 10px;
		}

		#radio_1 {
			width: 50%;
			text-align: center;
			background: red;
			color: #fff;
			border-radius: 5px 0px 0px 5px;
		}

		#radio_2 {
			width: 50%;
			text-align: center;
			background: #e0e0e0;
			border-radius: 0px 5px 5px 0px;
		}

		#radiocheck_2 {
			width: 50%;
			text-align: center;
			background: red;
			color: #fff;
			border-radius: 5px 0px 0px 5px;
		}

		#radiocheck_22 {
			width: 50%;
			text-align: center;
			background: #e0e0e0;
			border-radius: 0px 5px 5px 0px;
		}

		.condition {
			width: 90%;
			margin: 2px 5%;
			padding: 0px;
			font-size: 1em;
		}

		.condition>ul {
			line-height: 36px;
		}

		.condition>ul>li {
			width: 100%;
			text-indent: 1em;
		}

		.condition .right {
			float: right;
			margin-right: 5%;
			display: none;
		}

		#measures {
			width: 95%;
			margin: 5px 5px 5px 5px;
			border: 1px solid #e0e0e0;
			border-radius: 5px;
			padding: 2px;
			line-height: 26px;
		}

		#feedback {
			width: 95%;
			margin: 5px 5px 5px 5px;
			border: 1px solid #e0e0e0;
			border-radius: 5px;
			padding: 2px;
			line-height: 26px;
		}
		/*.email, .passwd, .btn {margin:3px 10px;}*/

		.btn {
			margin: 25px 10px;
		}

		.btn {
			background: #3A8B7A;
			color: #fff;
			height: 40px;
			text-align: center;
			line-height: 40px;
			font-size: 20px;
			border-radius: 5px;
		}
		/* 底部样式 */

		.bottom {
			/*position: absolute;bottom: 0;*/
			width: 100%;
			height: 50px;
			text-align: center;
			/*padding-bottom: 20px;*/
			font-size: 12px;
		}

		input {
			outline: none;
		}

		.nav-tabs {
			/*padding: 8px 15px;*/
			border: none;
		}

		.nav-tabs>li {
			float: left;
			margin-bottom: -15px;
		}

		.nav>li {
			position: relative;
			display: block;
		}

		.nav-tabs>li.active>a {
			background-color: #3A8B7A !important;
			border: 1px solid #3A8B7A !important;
			color: #fff;
		}

		.nav-tabs>li>a {
			padding: 4px 10px;
			border: 1px solid transparent;
			border-radius: 4px;
			font-size: 14px;
			-webkit-transition: background 0.2s ease;
			-moz-transition: background 0.2s ease;
			-o-transition: background 0.2s ease;
			transition: background 0.2s ease;
		}

		.nav-tabs>li>a {
			margin-right: 2px;
			line-height: 1.42857143;
			border: 1px solid transparent;
			border-radius: 0 0 0 0;
		}

		.nav>li>a {
			position: relative;
			display: block;
			padding: 10px 15px;
		}

		.nav-tabs>li>a {
			padding: 4px 10px !important;
			font-size: 16px !important;
		}

		a {
			color: #444;
			text-decoration: none;
			outline: none;
		}

		.clear {
			clear: both;
		}

		.reason {
			/*width: 100%;*/
			margin: 10px 10px 0px 30px;
			border-bottom: 1px solid #8a8a8a;
			line-height: 2;
		}
		.reason span{
			padding-left: 20px;
		}
	</style>
</head>

<body style="background-color:#fff">
	<div class="top">
		<div id="main">
				<div class="option" style="font-size: 1.3em;">驳回情况：</div>
				<div id="bohui_reason">
					<div class="reason">
						<b>省测试人</b><span>2012-12-25 12:12:12</span>
						<p>打瞌睡来恢复的卡是恢复熬枯受淡换福卡舒服多了咖啡</p>
					</div>
					<div class="reason">
						<b>省测试人</b><span>2012-12-25 12:12:12</span>
						<p>打瞌睡来恢复的卡是恢复熬枯受淡换福卡舒服多了咖啡</p>
					</div>
				</div>



			<div class="clear"></div>
			<div style="display:none">
				<div class="select clear">
					<div class="option" style="margin-top:20px;"><em style="color:red;">*</em>真实性：</div>
					<div class="condition">
						<input type="hidden" id="isreal" name="isreal" value="0">
						<input type="hidden" id="area_id" name="area_id" value="0">
					</div>
					<div class="option"><em style="color:red;">*</em>处置结果：</div>
					<div class="condition" style="width: 95%; ">
						<textarea style="overflow:scroll;font-size:16px;display:none;" id="measures" name="measures" cols="28%" rows="12"></textarea>
					</div>
					<input type="hidden" id="is_media" name="is_media" value="1">
					<div class="option"><em style="color:red;">*</em>媒体反馈：</div>
					<div class="condition" style="width: 95%; ">
						<textarea style="overflow:scroll;font-size:16px;display:none;" id="feedback" name="feedback" cols="28%" rows="5"></textarea>
					</div>
				</div>
				<ul id='ul_imgList' class="aui-list-view aui-grid-view">
				</ul>
			</div>
			<div id="checkDiv">
				<input type="hidden" id="deal_status" name="deal_status" value="22">
				<div>
					<div class="option"><em style="color:red;">*</em>驳回原因：</div>
					<div class="condition" style="text-align:center;width: 95%;margin:10px 10px 0px 10px;">
						<textarea style="overflow:scroll;font-size:16px;margin-bottom:0px;" id="dealturn_sug" name="dealturn_sug" cols="28%" rows="12"></textarea>
					</div>
				</div>
			</div>
		</div>
		<div id="clear_5"></div>
		<div id="btn_tj" class="btn" tapmode="buyhover" onclick="goto_SubmitDataFun()">提 交</div>
		<!-- <div style="font-size:14px;margin:5px">
			1、带“<em style="color:red;">*</em>”项为必填项<br> 2、区县级处置人点击“提交”后，等待市级处置人审核后状态改为“处置完毕”。
			<br/> 3、市级处置人点击“提交”后，可以直接设置状态为“处置完毕”。
		</div> -->
	</div>

	<!---------------------------底部信息------------------------------------->
	<div class="bottom">

	</div>
	<!---------------------------底部信息------------------------------------->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script>
<script type="text/javascript">
	apiready = function() {
		goto_loadInfoDetailFun();
	}


	function goto_loadInfoDetailFun() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误'
			});
			return;
		}
		api.showProgress({
			style: 'default',
			animationType: 'fade',
			title: '',
			text: '',
			modal: false
		});

		var MD5 = new Hashes.MD5;
		var access_token = Alpe_getLocalStorge("access_token");
		var admin_id = Alpe_getLocalStorge("admin_id");
		var sign = MD5.hex(access_token + admin_id + infoID + 'datas/getMsg1.0syjqingbao');

		var url = Alpe_ApiUrl + 'r=datas/getMsg&access_token=' + access_token + '&admin_id=' + admin_id +
			'&message_id=' + infoID +
			'&v=1.0&sign=' + sign;
		console.log(url);
		api.ajax({
			url: url,
			method: 'get',
			cache: false,
			timeout: 30,
			dataType: 'json'
		}, function(ret, err) {
			if (ret) {
				if ("100" == ret.success) {
					if (ret.isreal == "1" || ret.isreal == "2" || ret.isreal == "3" || ret.isreal == "4") {
						openSelect(ret.isreal);
					}

					var html='';
					$("#bohui_reason").html(html);
					$.each(ret.turnlist, function(index, v) {
						html+='<div class="reason">'+
											'<b>'+v.realname+'</b><span>'+v.op_time+'</span>'+
											'<p>'+v.dealturn_sug+'</p>'+
										'</div>';
					})
					$("#bohui_reason").html(html);

					$("#area_id").val(ret.forwarding_area_id);
					$("#measures").val(ret.deal_result);
					$("#is_media").val(ret.is_media);
					$("#feedback").val(ret.feedback);
					$("#feedback").removeAttr("readonly");
					$("#measures").removeAttr("readonly");
					$("#btn_tj").show();

					$("#ul_imgList").hide();
					$("#ul_imgList").html('');


					$(".isreal").removeAttr("onclick");
					$(".is_media").removeAttr("onclick");
					$("#feedback").attr('readonly', true);
					$("#measures").attr('readonly', true);
					$("#ul_imgList").html('');

					$("#btn_tj").html("审核并提交");
					if (ret.img_path != undefined) {
						$("#ul_imgList").show();
						$.each(ret.img_path, function(index, v) {
							var html = "<li class='aui-list-view-cell aui-img aui-col-xs-6' style='position: relative;text-align: center;margin: 0 auto'>" +
								"<input class='alpenlicebe_20151204_hf_img_list' type='hidden' value='" + v.img_path + "'/>" +
								"<img style='height:180px' class='aui-img-object' src='" + v.img_path_show + "'> " +
								"<div style='text-align: center; padding-top: 5px; position: absolute;z-index: 999;top: 130px; left: 10px; bottom: 0; right: 0;'>" +
								"<button onclick=goto_AddImageFun_show('" + v.img_path_show + "'); style='width:48%;' class='aui-btn aui-btn-primary'>查看</button>" +
								"</div>" +
								"</li>";
							$("#ul_imgList").prepend(html);
						});
					}

					api.hideProgress();
					if (ret.deal_status == 0) {
						// api.closeFrame();
						// api.closeWin();
						// api.alert({
						// 	title: '系统提示',
						// 	msg: '请先设置“处置中”'
						// });
					}
				} else {
					api.alert({
						title: '系统提示',
						msg: ret.message
					});
					api.hideProgress();
				}
				api.hideProgress();
			} else {
				api.alert({
					title: '系统提示',
					msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
				});
				api.hideProgress();
			}
		});
	}
	//选中审核状态
	function openRadioCheck(id) {
		$("#checkShowDiv").hide();
		$("#checkDiv").show();
		// alert('应该'+id);
		//将之前选中的样式复原
		var selected_id = document.getElementById('deal_status').value;
		if (selected_id == id) {
			return;
		}
		// alert('原来'+selected_id);
		if (selected_id != "0") {
			document.getElementById('radiocheck_' + selected_id).style.background = "#e0e0e0";
			document.getElementById('radiocheck_' + selected_id).style.color = "#333";
		}
		//标记处已选中的样式
		if (id != selected_id) {
			document.getElementById('radiocheck_' + id).style.background = "red";
			document.getElementById('radiocheck_' + id).style.color = "#fff";
			//输出已选中的
			document.getElementById('deal_status').value = id;
		} else {
			document.getElementById('deal_status').value = "2";
		}
		if (document.getElementById('deal_status').value == 22) {
			$("#dealturn_sug").parent().parent().show();
		} else {
			$("#dealturn_sug").val("");
			$("#dealturn_sug").parent().parent().hide();
		}
	}
	//选中真实性
	function openSelect(id) {
		//将之前选中的样式复原
		var selected_id = document.getElementById('isreal').value;
		if (selected_id != "0") {
			document.getElementById('duigou_' + selected_id).style.display = "none";
			document.getElementById('selected_' + selected_id).style.background = "#fff";
			document.getElementById('selected_' + selected_id).style.color = "#333";
		}

		//标记处已选中的样式
		if (id != selected_id) {
			document.getElementById('duigou_' + id).style.display = "block";
			document.getElementById('selected_' + id).style.background = "#e0e0e0";
			document.getElementById('selected_' + id).style.color = "red";
			document.getElementById('isreal').value = id;
		} else {
			document.getElementById('isreal').value = "0";
		}
	}

	//选中有无媒体反馈
	function openRadio(id) {
		// alert('应该'+id);
		//将之前选中的样式复原
		var selected_id = document.getElementById('is_media').value;
		if (selected_id == id) {
			return;
		}

		// alert('原来'+selected_id);
		if (selected_id != "0") {
			document.getElementById('radio_' + selected_id).style.background = "#e0e0e0";
			document.getElementById('radio_' + selected_id).style.color = "#333";
		}
		//标记处已选中的样式
		if (id != selected_id) {
			document.getElementById('radio_' + id).style.background = "red";
			document.getElementById('radio_' + id).style.color = "#fff";
			//输出已选中的
			document.getElementById('is_media').value = id;
		} else {
			document.getElementById('is_media').value = "0";
		}
	}
	//选中真实性
	function openSelect(id) {
		$("#isreal").val(id);
		if (id == 1) {
			$(".isreal").html('完全属实');
		} else if (id == 2) {
			$(".isreal").html('部分属实');
		} else if (id == 3) {
			$(".isreal").html('不属实');
		} else if (id == 4) {
			$(".isreal").html('其他');
		}
	}

	function goto_SubmitDataFun() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误4'
			});
			return;
		}
		/*获取上传图片列表*/
		var imgList = "";
		var imgListarr = [];
		$('.alpenlicebe_20151204_hf_img_list').each(function(index) {
			imgList += $(this).val() + '|';
			imgListarr.push({
				pic_path: $(this).val()
			});
		});
		var measures = $("#measures").val();
		var deal_status = $("#deal_status").val();
		var feedback = $("#feedback").val();
		var is_media = $("#is_media").val();
		var isreal = $("#isreal").val();
		var dealturn_sug = $("#dealturn_sug").val();
		if (isreal == '0') {
			api.alert({
				title: '系统提示',
				msg: '真实性不能为空'
			});
			return;
		}
		if (measures == '') {
			api.alert({
				title: '系统提示',
				msg: '处置结果不能为空'
			});
			return;
		}
		//      if(feedback=='' || document.getElementById('is_media').value == "有"){
		//       	api.alert({title:'系统提示',msg:'媒体反馈不能为空'});
		//			return;
		//      }

		if (document.getElementById('is_media').value == "1") {
			if (feedback == '') {
				api.alert({
					title: '系统提示',
					msg: '媒体反馈不能为空'
				});
				return;
			}

		}

		if (deal_status == 22) {
			if (dealturn_sug == '') {
				api.alert({
					title: '系统提示',
					msg: '驳回原因不能为空'
				});
				return;
			}
		}

		api.confirm({
			title: '确认是否提交',
			msg: '提交成功后将返回原信息页面，可返回列表查看提交信息。',
			buttons: ['确定', '取消']
		}, function(ret, err) {
			if (ret.buttonIndex == 1) {
				api.showProgress({
					style: 'default',
					animationType: 'fade',
					title: '',
					text: '',
					modal: false
				});

				var MD5 = new Hashes.MD5;
				var access_token = Alpe_getLocalStorge("access_token");
				var admin_id = Alpe_getLocalStorge("admin_id");
				var sign = MD5.hex(access_token + admin_id + infoID + 'datas/setResult1.0syjqingbao');
				var area_id = $("#area_id").val()
					/*var url = Alpe_ApiUrl+'r=datas/setResult&access_token='+access_token+'&admin_id='+admin_id
						+'&message_id='+infoID
						+'&imgList='+imgList
						+'&feedback='+feedback
						+'&is_media='+is_media +'&isreal='+isreal
						+'&area_id=-99&deal_status='+deal_status
						+'&measures='+measures +'&deal_result='+measures
						+'&v=1.0&sign='+sign; */
				var url = Alpe_ApiUrl + 'r=datas/setResult&access_token=' + access_token + '&admin_id=' + admin_id +
					'&message_id=' + infoID +
					'&is_media=' + is_media + '&isreal=' + isreal +
					'&area_id=' + area_id + '&deal_status=' + deal_status +
					'&v=1.0&sign=' + sign;
				console.log(url);
				var pap = {
					imgList: imgList,
					feedback: feedback,
					measures: measures,
					deal_result: measures,
					dealturn_sug: dealturn_sug
				};
				// console.log(JSON.stringify(pap));

				var dataobj = {
					img_path: imgListarr,
					feedback: feedback,
					measures: measures,
					deal_result: measures,
					isreal: isreal,
					is_media: is_media,
					dealturn_sug: dealturn_sug
				};

				var datas = JSON.stringify(dataobj);
				api.writeFile({
					path: 'fs://deallist' + $("#area_id").val() + '.dat',
					data: datas
				}, function(ret, err) {
					// console.log(JSON.stringify(ret));
				});
				api.ajax({
					url: url,
					method: 'post',
					cache: false,
					returnAll: false,
					data: {
						values: pap
					},
					dataType: 'json'
				}, function(ret, err) {
					console.log($api.jsonToStr(ret));
					if (ret) {
						// console.log(ret);
						api.hideProgress();
						api.toast({
							msg: ret.message,
							duration: 2000,
							location: 'middle'
						});
						if (ret.success == "101") {
							/*注册已经处理的事件，刷新详细页面*/
							api.sendEvent({
								name: 'Alpe_Event_yq_dosomething',
								extra: {
									keyID: 'alpenlicebe'
								}
							});
							setTimeout(function() {
								api.closeWin();
							}, 900);
						}
					} else {
						api.alert({
							title: '系统提示',
							msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
						});
						api.hideProgress();
					}
				});
			}
		});
	}
</script>

</html>
